package com.example.controller;

import com.example.pojo.Persion;
import com.example.pojo.User;
import com.example.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class UserController {

    @Autowired
    public UserService userService;

    @Value("${test}")
    private String test;

    @Autowired
    private Persion persion;

    @GetMapping("/getUsername")
    public String getUsername(){
        System.out.println(test);
        return test;
    }

    @GetMapping("/getPersion")
    public Persion getPerssion(){
        System.out.println(persion.toString());
        return persion;

    }

    /**
     * @Author: yajie
     * @Date: 18:13 2020/7/4
     * @Parms []
     * @ReturnType: java.util.List<com.example.pojo.User>
     * @Description: 查询所有用户
    */
    @GetMapping("/findAll")
    public List<User> findAll(){
        List<User> users = userService.findAll();
        System.out.println(users.toString());
        return users;
    }
    
    /**
     * @Author: yajie 
     * @Date: 19:56 2020/7/4
     * @Parms []
     * @ReturnType: java.util.List<com.example.pojo.User>
     * @Description: 从redis中查询用户信息
    */
    @GetMapping("/getUserByRedis")
    public String getUserByRedis(){
        String userAll = userService.getUserByRedis();
        return userAll;
    }

}
